package com.ezgo.erc.webservice;

import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebService;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import com.ezgo.erc.entity.Syslog;
import com.ezgo.erc.master.utils.Constants;
import com.ezgo.erc.master.utils.DataOrigin;
import com.ezgo.erc.master.utils.GlobeStatus;
import com.ezgo.erc.master.utils.StringUtil;
import com.ezgo.erc.utils.SysLogUtil;

/**
 * 
 * (WEBSERVICE)模块 TODO(酒店核心服务)
 * 
 * @author devintam
 * @date 2015年7月23日 下午2:18:24
 *
 */
@Component
@WebService(serviceName = "HotelCoreService")
public class HotelCoreService {

	protected static Logger logger = LoggerFactory.getLogger(HotelCoreService.class);

	/**
	 * 
	 * TODO(酒店信息搜索)
	 *
	 * @param jsonStr
	 *            参数
	 * @return String
	 */
	@WebMethod
	public String HotelSearch(@WebParam(name = Constants.PARAM_JSONSTR) String jsonStr) {
		String resultStr = null;
		try {
			if (StringUtil.isBlank(jsonStr) || !StringUtil.isJson(jsonStr)) {
				resultStr = String.format(Constants.JSON_RESP_NOMES_TEMPLATE, GlobeStatus.API_BADREQ.statusCode, GlobeStatus.API_BADREQ.zhStatusMsg,
						DataOrigin.IBE.getValue());
			} else {
				// Hotelinfo req = JSON.parseObject(jsonStr, Hotelinfo.class);
				/** 请求bean 参数验证 **/
				// if (req.isBadParam()) {
				// resultStr = String.format(
				// Constants.JSON_RESP_NOMES_TEMPLATE,
				// GlobeStatus.API_BADREQ.statusCode,
				// GlobeStatus.API_BADREQ.zhStatusMsg,
				// DataOrigin.IBE.getValue());
				// } else
				// resultStr = JSON.toJSONString(SpringContext.getBean(
				// HotelinfoService.class).getHotelDinfo(
				// Maps.newHashMap()));
			}
		} catch (Exception e) {
			logger.error(String.format(Constants.EX_FORMAT_STR, this.getClass().getName(), e.getMessage()));
			resultStr = String.format(Constants.JSON_RESP_NOMES_TEMPLATE, GlobeStatus.API_INTER_ERROR.statusCode,
					GlobeStatus.API_INTER_ERROR.zhStatusMsg, DataOrigin.IBE.getValue());
			SysLogUtil.saveLog(new Syslog(Constants.TYPE_EXCEPTION, 0L, "", "", "WS", jsonStr, "", e.getMessage()));
		}
		return resultStr;
	}
}
